<template>
    <el-dialog v-model="state.isShowDialog" width="769px">
    <OrgTree ref="orgTreeRef" class="w100" :isNeedAllChoice="false"/>
    <template #footer>
        <span class="dialog-footer">
            <el-button @click="closeDialog" size="default">{{$t('message.userOperation.cancel')}}</el-button>
            <el-button type="primary" @click="confirm" size="default">{{$t('message.userOperation.submit')}}</el-button>
        </span>
    </template>
    </el-dialog>
</template>
<script setup lang="ts">
import { ref,reactive } from 'vue';
import OrgTree from '/@/views/system/org/component/orgTree.vue';
const orgTreeRef = ref();
const state = reactive({
	isShowDialog: false,
    dataScope:{
        apiRoute:'',
        dataScopeType:'DataScopeDefine',//这里默认全部都是自定义
        defineScopeOrgList:''
    }
});
const openDialog=(data:any)=>{
    state.isShowDialog=true;
    state.dataScope.apiRoute=data.apiRoute;
    setTimeout(() => {
		orgTreeRef.value?.setCheckedKeys(data.defineScopeOrgList);
	}, 100);
}
// 关闭弹窗
const closeDialog = () => {
	state.isShowDialog = false;
};
const emits = defineEmits(['backData']);
//确定
const confirm=()=>{
    //从组件获取选取data
    state.dataScope.defineScopeOrgList= orgTreeRef.value?.getCheckedKeys();
    //将选择数据回传
    emits("backData",state.dataScope)
    closeDialog();
}

defineExpose({openDialog});
</script>